<template>
  <div>
    <h2 style="text-align: center;">用户信息完善页面</h2>
    <table class="table table-bordered">
      <tr>
        <td>真实姓名</td>
        <td>
          <input type="text" v-model="info.xname">
        </td>
      </tr>
      <tr>
        <td>性别</td>
        <td>
          <input type="radio" name="sex" value="男" checked v-model="info.xsex">男
          <input type="radio" name="sex" value="女" v-model="info.xsex">女
        </td>
      </tr>
      <tr>
        <td>身份证号</td>
        <td>
          <input type="text" v-model="info.xcard">
        </td>
      </tr>
      <tr>
        <td>类别</td>
        <td>
          <select v-model="info.xtype">
            <option>请选择</option>
            <option value="管理员" >管理员</option>
            <option value="普通用户">普通用户</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>年收入</td>
        <td>
          <input type="text" v-model="info.xprice">
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <input type="button" value="完善" @click="wanshan">
        </td>
      </tr>
    </table>

  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
import {useRouter} from 'vue-router';
let router=useRouter();
const info=ref({
  xname:"",
  xsex:"",
  xcard:"",
  xtype:"",
  xprice:"",
})
//完善函数
const wanshan=()=>{
  if(info.value.xname==""||info.value.xsex==""||info.value.xcard==""||info.value.xprice=="")
  {
    alert("请完善信息");
    return;
  }
  axios({
    url:"http://localhost:8322/api/User/userxinxiAdd",
    method:"post",
    data:info.value
  }).then((res)=>{
    if(res.data>0)
    {
      alert("完善成功");
      if(info.value.xtype=="管理员")
      {
        router.push("/AdminshowView")
      }
      else
      {
        router.push("/UsershowView")
      }

  
    }
    else
    {
      alert("完善失败");
    }
  })

}

</script>

<style scoped>

</style>